package com.zhu.ttwords.model;

import com.zhu.ttwords.TTWORDS;
import com.zhu.ttwords.bean.MainBean;
import com.zhu.ttwords.common.DBTool;
import com.zhu.ttwords.common.DateTool;

/**
 * Created by KnightYe on 2015/4/9.
 * read user study date.and show on main activity.
 */
public class MainModel implements IMainModel {

    @Override
    public MainBean loadMainData() {
        MainBean bean = new MainBean();
        String[] params0 = new String[1];
        String[] params = new String[2];
        String[] params1 = new String[2];
        params0[0] = TTWORDS.getAppSetting().getUserId();
        params[0] = DateTool.getCurrentDateTime();
        params[1] = TTWORDS.getAppSetting().getUserId();
        params1[0] = DateTool.addOnCurrentDateTime(1);
        params1[1] = TTWORDS.getAppSetting().getUserId();

        long total = DBTool.count(TTWORDS.SQL_MAIN_TOTAL, params0);
        long today = DBTool.count(TTWORDS.SQL_MAIN_TODAY, params);
        long tomorrow = DBTool.count(TTWORDS.SQL_MAIN_TOMORROW, params1);
        bean.setTotal(total);
        bean.setToday(today);
        bean.setTomorrow(tomorrow);
        return bean;
    }
}
